﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Utility;
using VAdvantage.DataBase;
using VAdvantage.Logging;

namespace VAdvantage.Model
{
    public class MModuleMenuFolder:VAdvantage.Model.X_AD_ModuleMenuFolder
    {

        public MModuleMenuFolder(Ctx ctx, int AD_ModuleMenuFolder_ID, string trx)
            : base(ctx, AD_ModuleMenuFolder_ID, trx)
        {
 
        }

        protected override bool AfterSave(bool newRecord, bool success)
        {
            if (IsParentFolder())
            {
                string sql = @"update AD_ModuleMenuFolder set isParentFolder='N' where AD_ModuleMenuFolder_ID!=" 
                    + GetAD_ModuleMenuFolder_ID() + " and AD_ModuleInfo_ID=" + GetAD_ModuleInfo_ID();
                if (DB.ExecuteQuery(sql) > -1)
                {
                    return true;
                }
                else
                {
                    log.Log(Level.WARNING, "AD_ModuleMenuFolder Not Updated");
                    return false;
                }
            }
            return true;
        }

    }
}
